News All Tests
Current file: /home/estudydev/workspace/MSP09/web/news/tests/class.file.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 26
1.51 %1.51%
1.51% 5 / 331
 
File
100.00 %100.00%
100.00% 1 / 1
0.00 %0.00%
0.00% 0 / 26
0.31 %0.31%
0.31% 1 / 325
 public function setOrigFileName($origFileName)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getOrigFileName()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function setType($type)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getType()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getSize()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function setSize($size)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function setCounter($counter)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function setExtension($extension)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function getExtension()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getPathToFile()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4
 public function isFileVisible()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 7
 private function getUserIcons()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 29
 protected function getContent($url)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 10
 private function getFaviconUrl($url)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 11
 private function remoteFileExists($url)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 27
 public function getHTMLString($statisticView = false, $cssClass = '')
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 84
 public function getFileOptionHTML($option)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 10
 private function getCopyFileHTML()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 22
 private function getFileLink()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
 private function getStatisticLink()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
 private function getDownloadCount()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
 private function getDownloadStatisticHTML()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 7
 private function getDeleteFileHTML()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
 private function getDescriptionHTML()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 private function getStatisticHTML()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 70
 public function archiverAccept(ResourceVisitor $visitor, $parentPath = '/')
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2


       1                 : <?php                                                                                                                                                                                                                                                                                                      
       2                 : /*--------------------------------------------------------------------------+                                                                                                                                                                                                                              
       3                 : This file is part of eStudy.                                                                                                                                                                                                                                                                               
       4                 : ressourcen/classes/filemanager/class.file.inc.php                                                                                                                                                                                                                                                          
       5                 : - Modulgruppe:  File Manager                                                                                                                                                                                                                                                                               
       6                 : - Beschreibung: Klasse "File"                                                                                                                                                                                                                                                                              
       7                 : - Version:      0.4, 08.01.08                                                                                                                                                                                                                                                                              
       8                 : - Autor(en):    Tobias Wild <tobias.wild@mni.fh-giessen.de>                                                                                                                                                                                                                                                
       9                 : +---------------------------------------------------------------------------+                                                                                                                                                                                                                              
      10                 : This program is free software; you can redistribute it and/or                                                                                                                                                                                                                                              
      11                 : modify it under the terms of the GNU General Public License                                                                                                                                                                                                                                                
      12                 : as published by the Free Software Foundation; either version 2                                                                                                                                                                                                                                             
      13                 : of the License, or any later version.                                                                                                                                                                                                                                                                      
      14                 : +---------------------------------------------------------------------------+                                                                                                                                                                                                                              
      15                 : This program is distributed in the hope that it will be useful,                                                                                                                                                                                                                                            
      16                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                                                                                                                                                                             
      17                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                                                                                                                                                                              
      18                 : GNU General Public License for more details.                                                                                                                                                                                                                                                               
      19                 : You should have received a copy of the GNU General Public License                                                                                                                                                                                                                                          
      20                 : along with this program; if not, write to the Free Software                                                                                                                                                                                                                                                
      21                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                                                                                                                                                                                
      22                 : +--------------------------------------------------------------------------*/                                                                                                                                                                                                                              
      23                 :                                                                                                                                                                                                                                                                                                            
      24               1 : if ( !defined("PATH_TO_ROOT") ) {                                                                                                                                                                                                                                                                          
      25               0 :     define( "PATH_TO_ROOT", "../../../" );                                                                                                                                                                                                                                                                 
      26               0 : }                                                                                                                                                                                                                                                                                                          
      27                 :                                                                                                                                                                                                                                                                                                            
      28               1 : require_once ("class.resource.inc.php");                                                                                                                                                                                                                                                                   
      29               1 : require_once ("interface.resourcevisitor.inc.php");                                                                                                                                                                                                                                                        
      30               1 : require_once ("class.usertools.inc.php");                                                                                                                                                                                                                                                                  
      31                 : //                                                                                                                                                                                                                                                                                                         
      32               1 : class File extends Resource {                                                                                                                                                                                                                                                                              
      33                 :     protected $origFileName;                                                                                                                                                                                                                                                                               
      34                 :     protected $type;                                                                                                                                                                                                                                                                                       
      35                 :     protected $size;                                                                                                                                                                                                                                                                                       
      36                 :     protected $counter;                                                                                                                                                                                                                                                                                    
      37                 :     protected $extension;                                                                                                                                                                                                                                                                                  
      38                 :                                                                                                                                                                                                                                                                                                            
      39                 :     public function setOrigFileName ( $origFileName ) {                                                                                                                                                                                                                                                    
      40               0 :         $this->origFileName = $origFileName;                                                                                                                                                                                                                                                               
      41               0 :     }                                                                                                                                                                                                                                                                                                      
      42                 :                                                                                                                                                                                                                                                                                                            
      43                 :     public function getOrigFileName() {                                                                                                                                                                                                                                                                    
      44               0 :         return $this->origFileName;                                                                                                                                                                                                                                                                        
      45                 :     }                                                                                                                                                                                                                                                                                                      
      46                 :                                                                                                                                                                                                                                                                                                            
      47                 :     public function setType ( $type ) {                                                                                                                                                                                                                                                                    
      48               0 :         $this->type = $type ;                                                                                                                                                                                                                                                                              
      49               0 :     }                                                                                                                                                                                                                                                                                                      
      50                 :                                                                                                                                                                                                                                                                                                            
      51                 :     public function getType() {                                                                                                                                                                                                                                                                            
      52               0 :         return $this->type;                                                                                                                                                                                                                                                                                
      53                 :     }                                                                                                                                                                                                                                                                                                      
      54                 :                                                                                                                                                                                                                                                                                                            
      55                 :     public function getSize() {                                                                                                                                                                                                                                                                            
      56               0 :         return $this->size;                                                                                                                                                                                                                                                                                
      57                 :     }                                                                                                                                                                                                                                                                                                      
      58                 :                                                                                                                                                                                                                                                                                                            
      59                 :     public function setSize ( $size ) {                                                                                                                                                                                                                                                                    
      60               0 :         $this->size = $size;                                                                                                                                                                                                                                                                               
      61               0 :     }                                                                                                                                                                                                                                                                                                      
      62                 :                                                                                                                                                                                                                                                                                                            
      63                 :     public function setCounter ( $counter ) {                                                                                                                                                                                                                                                              
      64               0 :         $this->counter = $counter ;                                                                                                                                                                                                                                                                        
      65               0 :     }                                                                                                                                                                                                                                                                                                      
      66                 :                                                                                                                                                                                                                                                                                                            
      67                 :     public function setExtension ( $extension ) {                                                                                                                                                                                                                                                          
      68               0 :         $this->extension = $extension ;                                                                                                                                                                                                                                                                    
      69               0 :     }                                                                                                                                                                                                                                                                                                      
      70                 :                                                                                                                                                                                                                                                                                                            
      71                 :     /**                                                                                                                                                                                                                                                                                                    
      72                 :      * Getter for File extension property.                                                                                                                                                                                                                                                                 
      73                 :      *                                                                                                                                                                                                                                                                                                     
      74                 :      * @return String Extenstion                                                                                                                                                                                                                                                                           
      75                 :      */                                                                                                                                                                                                                                                                                                    
      76                 :     public function getExtension () {                                                                                                                                                                                                                                                                      
      77               0 :         return $this->extension;                                                                                                                                                                                                                                                                           
      78                 :     }                                                                                                                                                                                                                                                                                                      
      79                 :                                                                                                                                                                                                                                                                                                            
      80                 :     public function getPathToFile() {                                                                                                                                                                                                                                                                      
      81               0 :         global $settings;                                                                                                                                                                                                                                                                                  
      82                 :         // Verzeichnis dass die hochgeladenen Dateien enthält                                                                                                                                                                                                                                             
      83               0 :         $basedir = PATH_TO_ROOT.$settings["upload_path"].'filemanager/courseID/'.$this->courseID;                                                                                                                                                                                                          
      84                 :         //die datei wie sie auf dem server liegt (der dateiname ist verschlüsselt)                                                                                                                                                                                                                        
      85               0 :         $filename = sprintf("%s/%s", $basedir, $this->link);                                                                                                                                                                                                                                               
      86               0 :         return $filename;                                                                                                                                                                                                                                                                                  
      87                 :     }                                                                                                                                                                                                                                                                                                      
      88                 :                                                                                                                                                                                                                                                                                                            
      89                 :     public function isFileVisible() {                                                                                                                                                                                                                                                                      
      90               0 :         global $db;                                                                                                                                                                                                                                                                                        
      91               0 :         if (($_SESSION['usergroup'] == STUDENT || $_SESSION['usergroup'] == ALUMNUS || $_SESSION['usergroup'] == SCHUELER || $_SESSION['usergroup'] == GAST) && $this->visibleType != 1 && $_SESSION['userid'] != $this->userID) {                                                                         
      92                 :             // Wenn Tutor oder Student und darf nicht sehen spezielle DB abfragen                                                                                                                                                                                                                          
      93               0 :             if (!isset($_SESSION["assistent"]) || (isset($_SESSION["assistent"]) && $this->visibleType == 3 && $_SESSION['userid'] != $this->userID)) {                                                                                                                                                    
      94               0 :                 $visible = $db->get_var("SELECT count(*) FROM filevisible WHERE userID='".Data::toMysql( $_SESSION['userid'] )."' AND fileID='". Data::toMysql( $this->fileID )."'");                                                                                                                      
      95               0 :                 return ($visible >= 1);                                                                                                                                                                                                                                                                    
      96                 :             }                                                                                                                                                                                                                                                                                              
      97               0 :         }                                                                                                                                                                                                                                                                                                  
      98               0 :         return true;                                                                                                                                                                                                                                                                                       
      99                 :     }                                                                                                                                                                                                                                                                                                      
     100                 :                                                                                                                                                                                                                                                                                                            
     101                 :     private function getUserIcons() {                                                                                                                                                                                                                                                                      
     102               0 :         global $VISIBLE_ICONS;                                                                                                                                                                                                                                                                             
     103               0 :         $imgFolder = $this->fileManager->getImgFolder();                                                                                                                                                                                                                                                   
     104                 :         //$EDIT = "<img src='".$imgFolder."edittypes/lock_edit.gif' alt='edit Symbol' />";                                                                                                                                                                                                                 
     105                 :         //Performance-Tuning: Image wird ab jetzt als CSS-Sprite geladen!                                                                                                                                                                                                                                  
     106               0 :         if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")                                                                                                                                                                                                                           
     107               0 :             $EDIT = "<img src='".$imgFolder."edittypes/lock_edit.gif' alt='edit Symbol' />";                                                                                                                                                                                                               
     108               0 :         else $EDIT = "<img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_lock_edit' alt='edit Symbol' />";                                                                                                                                                                                      
     109                 :         //$DELETE = "<img src='".$imgFolder."edittypes/lock_delete.gif' alt='delete Symbol' />";                                                                                                                                                                                                           
     110                 :         //Performance-Tuning: Image wird ab jetzt als CSS-Sprite geladen!                                                                                                                                                                                                                                  
     111               0 :         if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")                                                                                                                                                                                                                           
     112               0 :             $DELETE = "<img src='".$imgFolder."edittypes/lock_delete.gif' alt='delete Symbol' />";                                                                                                                                                                                                         
     113               0 :         else $DELETE = "<img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_lock_delete' alt='delete Symbol' />";                                                                                                                                                                                
     114               0 :         $FILEVISIBLE = "";                                                                                                                                                                                                                                                                                 
     115               0 :         if ($_SESSION['userid'] == $this->userID || $_SESSION['usergroup'] == ADMIN || ($_SESSION["usergroup"] == DOZENT && $_SESSION["course"] > 0)) {                                                                                                                                                    
     116                 :             //$EDIT = "<a title='Dateieigenschaften ver&auml;ndern' href='./edit.php?editID=".$this->fileID."'><img src='".$imgFolder."edittypes/edit.gif' alt='edit Symbol' /></a>";                                                                                                                      
     117                 :             //Performance-Tuning: Image wird ab jetzt als CSS-Sprite geladen!                                                                                                                                                                                                                              
     118               0 :             if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")                                                                                                                                                                                                                       
     119               0 :                 $EDIT = "<a title='Dateieigenschaften ver&auml;ndern' href='./edit.php?editID=".$this->fileID."'><img src='".$imgFolder."edittypes/edit.gif' alt='edit Symbol' /></a>";                                                                                                                    
     120               0 :             else $EDIT = "<a title='Dateieigenschaften ver&auml;ndern' href='./edit.php?editID=".$this->fileID."'><img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_edit_file' alt='edit Symbol' /></a>";                                                                                      
     121                 :             //$DELETE = "<a title='Datei l&ouml;schen' href='".$this->createLink(1, array('action' => "deleteFile", "actionID" => $this->fileID)) ."'><img src='".$imgFolder."edittypes/delete.gif' alt='delete Symbol' /></a>";                                                                           
     122                 :             //Performance-Tuning: Image wird ab jetzt als CSS-Sprite geladen!                                                                                                                                                                                                                              
     123               0 :             if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")                                                                                                                                                                                                                       
     124               0 :                 $DELETE = "<a title='Datei l&ouml;schen' href='".$this->createLink(1, array('action' => "deleteFile", "actionID" => $this->fileID)) ."'><img src='".$imgFolder."edittypes/delete.gif' alt='delete Symbol' /></a>";                                                                         
     125               0 :             else $DELETE = "<a title='Datei l&ouml;schen' href='".$this->createLink(1, array('action' => "deleteFile", "actionID" => $this->fileID)) ."'><img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_delete_file' alt='delete Symbol' /></a>";                                           
     126                 :             //Sichtbarkeitsanzeige für untergeordnete Dateien und Links setzen                                                                                                                                                                                                                            
     127               0 :             $visibleIcon = "";                                                                                                                                                                                                                                                                             
     128                 :             //beim Laden der Seite                                                                                                                                                                                                                                                                         
     129               0 :             if (isset($this->visibleType) && $this->visibleType >= 1 && $this->visibleType <= 3) {                                                                                                                                                                                                         
     130               0 :                 $visibleIcon = $VISIBLE_ICONS[$this->visibleType];                                                                                                                                                                                                                                         
     131               0 :             }                                                                                                                                                                                                                                                                                              
     132               0 :             $FILEVISIBLE = "<a title='Sichtbarkeit &auml;ndern' href='".$this->createLink(1, array('action' => "setRessourceVisibility", "actionID" => $this->fileID)) ."'>".$visibleIcon."</a>";                                                                                                          
     133               0 :         }                                                                                                                                                                                                                                                                                                  
     134               0 :         $copyFile = "";                                                                                                                                                                                                                                                                                    
     135                 :         //if ( $this->type == "file" ) $copyFile = "<a title='Datei in anderen Kurs kopieren' href='".$this->createLink(1, array('action' => "copyFile", "actionID" => $this->fileID)) ."'><img src='".$imgFolder."edittypes/copy.png' alt='copy Symbol' /></a>";                                          
     136                 :         //Performance-Tuning: Image wird ab jetzt als CSS-Sprite geladen!                                                                                                                                                                                                                                  
     137               0 :         if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")                                                                                                                                                                                                                           
     138               0 :             if ( $this->type == "file" ) $copyFile = "<a title='Datei in anderen Kurs kopieren' href='".$this->createLink(1, array('action' => "copyFile", "actionID" => $this->fileID)) ."'><img src='".$imgFolder."edittypes/copy.png' alt='copy Symbol' /></a>";                                        
     139               0 :         else if ( $this->type == "file" ) $copyFile = "<a title='Datei in anderen Kurs kopieren' href='".$this->createLink(1, array('action' => "copyFile", "actionID" => $this->fileID)) ."'><img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_copy_file' alt='copy Symbol' /></a>";          
     140                 :         //return "<a title='Dateibeschreibung anzeigen' href='".$this->createLink(1, array('action' => "infoFile", "actionID" => $this->fileID)) ."'><img src='".$imgFolder."edittypes/info.gif' alt='info Symbol' /></a>".$EDIT.$FILEVISIBLE.$DELETE.$copyFile;                                           
     141                 :         //Performance-Tuning: Image wird ab jetzt als CSS-Sprite geladen!                                                                                                                                                                                                                                  
     142               0 :         if(isset($_SESSION["UserStyle"]) && $_SESSION["UserStyle"] != "fh_yaml")                                                                                                                                                                                                                           
     143               0 :             return "<a title='Dateibeschreibung anzeigen' href='".$this->createLink(1, array('action' => "infoFile", "actionID" => $this->fileID)) ."'><img src='".$imgFolder."edittypes/info.gif' alt='info Symbol' /></a>".$EDIT.$FILEVISIBLE.$DELETE.$copyFile;                                         
     144               0 :         else return "<a title='Dateibeschreibung anzeigen' href='".$this->createLink(1, array('action' => "infoFile", "actionID" => $this->fileID)) ."'><img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_info_file' alt='info Symbol' /></a>".$EDIT.$FILEVISIBLE.$DELETE.$copyFile;           
     145                 :     }                                                                                                                                                                                                                                                                                                      
     146                 :                                                                                                                                                                                                                                                                                                            
     147                 :                                                                                                                                                                                                                                                                                                            
     148                 :     protected function getContent($url)                                                                                                                                                                                                                                                                    
     149                 :     {                                                                                                                                                                                                                                                                                                      
     150               0 :         $session = curl_init();                                                                                                                                                                                                                                                                            
     151               0 :         curl_setopt($session, CURLOPT_URL, $url);                                                                                                                                                                                                                                                          
     152               0 :         curl_setopt($session, CURLOPT_HEADER, false);                                                                                                                                                                                                                                                      
     153               0 :         curl_setopt($session, CURLOPT_RETURNTRANSFER, true);                                                                                                                                                                                                                                               
     154               0 :         curl_setopt($session, CURLOPT_CONNECTTIMEOUT, 6);                                                                                                                                                                                                                                                  
     155               0 :         curl_setopt($session, CURLOPT_TIMEOUT, 6);                                                                                                                                                                                                                                                         
     156                 :                                                                                                                                                                                                                                                                                                            
     157               0 :         $response = curl_exec($session);                                                                                                                                                                                                                                                                   
     158               0 :         if (curl_errno($session)!=0) $response = null;                                                                                                                                                                                                                                                     
     159                 :                                                                                                                                                                                                                                                                                                            
     160               0 :         curl_close($session);                                                                                                                                                                                                                                                                              
     161               0 :         return $response;                                                                                                                                                                                                                                                                                  
     162                 :     }                                                                                                                                                                                                                                                                                                      
     163                 :                                                                                                                                                                                                                                                                                                            
     164                 :                                                                                                                                                                                                                                                                                                            
     165                 :                                                                                                                                                                                                                                                                                                            
     166                 :     /**                                                                                                                                                                                                                                                                                                    
     167                 :      * Ermittelt den Pfad für das Favicon einer Webseite                                                                                                                                                                                                                                                  
     168                 :      *                                                                                                                                                                                                                                                                                                     
     169                 :      * @param string [$url] Die Adresse wo das Favicon gesucht werden soll                                                                                                                                                                                                                                 
     170                 :      * @return string FaviconUrl                                                                                                                                                                                                                                                                           
     171                 :      * @access public                                                                                                                                                                                                                                                                                      
     172                 :      */                                                                                                                                                                                                                                                                                                    
     173                 :     private function getFaviconUrl($url) {                                                                                                                                                                                                                                                                 
     174               0 :         if (strstr($url, "ftp://")) return false;                                                                                                                                                                                                                                                          
     175                 :         // Bei https-Links nur im http-Pendant suchen, da sonst eventuell Zertifikatsmeldungen angezeigt werden                                                                                                                                                                                            
     176               0 :         $url = str_replace("https://", "http://", $url);                                                                                                                                                                                                                                                   
     177               0 :         $file = $this->getContent($url);                                                                                                                                                                                                                                                                   
     178               0 :         if (is_null($file)) return false;                                                                                                                                                                                                                                                                  
     179               0 :         $lines = explode( "\n", $file );                                                                                                                                                                                                                                                                   
     180               0 :         $tag = $RT = $return = array();                                                                                                                                                                                                                                                                    
     181               0 :         foreach ( $lines as $line ) {                                                                                                                                                                                                                                                                      
     182                 :             /* This only works if the title and its tags are on one line */                                                                                                                                                                                                                                
     183               0 :             if (eregi("<link(.*)>", $line, $tag)) if (eregi(".*rel=\"SHORTCUT ICON\" (.*)", $tag[1], $RT) || eregi(".*rel=\"icon\" (.*)", $tag[1], $RT)) if (eregi(".*href=\"([^=]*)\"", $RT[1], $return)) break;                                                                                          
     184               0 :         }                                                                                                                                                                                                                                                                                                  
     185                 :                                                                                                                                                                                                                                                                                                            
     186               0 :         if (isset($return[1])) return $return[1];                                                                                                                                                                                                                                                          
     187               0 :         return false;                                                                                                                                                                                                                                                                                      
     188                 :     }                                                                                                                                                                                                                                                                                                      
     189                 :                                                                                                                                                                                                                                                                                                            
     190                 :     private function remoteFileExists($url) {                                                                                                                                                                                                                                                              
     191               0 :         $url_p = parse_url($url);                                                                                                                                                                                                                                                                          
     192               0 :         if (isset($url_p["host"])) {                                                                                                                                                                                                                                                                       
     193               0 :             $host = $url_p["host"];                                                                                                                                                                                                                                                                        
     194               0 :         } else {                                                                                                                                                                                                                                                                                           
     195               0 :             return false;                                                                                                                                                                                                                                                                                  
     196                 :         }                                                                                                                                                                                                                                                                                                  
     197               0 :         $errno = 0;                                                                                                                                                                                                                                                                                        
     198               0 :         $errstr = "";                                                                                                                                                                                                                                                                                      
     199               0 :         $fp = @fsockopen($host, 80, $errno, $errstr, 5);                                                                                                                                                                                                                                                   
     200               0 :         if (!$fp) {                                                                                                                                                                                                                                                                                        
     201               0 :             return false;                                                                                                                                                                                                                                                                                  
     202                 :         } else {                                                                                                                                                                                                                                                                                           
     203               0 :             fputs($fp, "HEAD ".$url." HTTP/1.1\r\n");                                                                                                                                                                                                                                                      
     204               0 :             fputs($fp, "HOST: ".$host."\r\n");                                                                                                                                                                                                                                                             
     205               0 :             fputs($fp, "Connection: close\r\n\r\n");                                                                                                                                                                                                                                                       
     206               0 :             $headers = "";                                                                                                                                                                                                                                                                                 
     207               0 :             while (!feof($fp)) {                                                                                                                                                                                                                                                                           
     208               0 :                 $headers.= fgets($fp, 128);                                                                                                                                                                                                                                                                
     209               0 :             }                                                                                                                                                                                                                                                                                              
     210                 :         }                                                                                                                                                                                                                                                                                                  
     211               0 :         fclose($fp);                                                                                                                                                                                                                                                                                       
     212               0 :         $arr_headers = explode("\n", $headers);                                                                                                                                                                                                                                                            
     213               0 :         if (isset($arr_headers[0])) {                                                                                                                                                                                                                                                                      
     214               0 :             if (!substr_count($arr_headers[0], "200 OK")) return false;                                                                                                                                                                                                                                    
     215               0 :             foreach($arr_headers as $header) {                                                                                                                                                                                                                                                             
     216               0 :                 $header = strtoupper($header);                                                                                                                                                                                                                                                             
     217               0 :                 if (substr_count($header, "CONTENT-TYPE:") && substr_count($header, "TEXT/HTML")) return false;                                                                                                                                                                                            
     218               0 :             }                                                                                                                                                                                                                                                                                              
     219               0 :             return true;                                                                                                                                                                                                                                                                                   
     220                 :         }                                                                                                                                                                                                                                                                                                  
     221               0 :         return false;                                                                                                                                                                                                                                                                                      
     222                 :     }                                                                                                                                                                                                                                                                                                      
     223                 :                                                                                                                                                                                                                                                                                                            
     224                 :     public function getHTMLString( $statisticView = false, $cssClass = "" ) {                                                                                                                                                                                                                              
     225               0 :         $templateTableRow = ( $statisticView ) ?                                                                                                                                                                                                                                                           
     226               0 :             new Template( PATH_TO_ROOT . "/ressourcen/templates/filelist_entry_statistic.html" )                                                                                                                                                                                                           
     227               0 :             : new Template( PATH_TO_ROOT . "/ressourcen/templates/filelist_entry.html" );                                                                                                                                                                                                                  
     228                 :                                                                                                                                                                                                                                                                                                            
     229               0 :         $activeFolder = $this->fileManager->getActiveFolder();                                                                                                                                                                                                                                             
     230               0 :         $action = $this->fileManager->getAction();                                                                                                                                                                                                                                                         
     231               0 :         $actionID = $this->fileManager->getActionID();                                                                                                                                                                                                                                                     
     232               0 :         $imgFolder = $this->fileManager->getImgFolder();                                                                                                                                                                                                                                                   
     233                 :                                                                                                                                                                                                                                                                                                            
     234               0 :         global $VISIBLE_ICONS;                                                                                                                                                                                                                                                                             
     235                 :                                                                                                                                                                                                                                                                                                            
     236               0 :         if (($_SESSION['usergroup'] == STUDENT && $this->visibleType != 1 && $_SESSION['userid'] != $this->userID)) {                                                                                                                                                                                      
     237                 :             // Wenn Tutor oder Student und darf nicht sehen spezielle DB abfragen                                                                                                                                                                                                                          
     238               0 :             if (!isset($_SESSION["assistent"]) || (isset($_SESSION["assistent"]) && $this->visibleType == 3 && $_SESSION['userid'] != $this->userID)) {                                                                                                                                                    
     239               0 :                 $visible = $db->get_var("SELECT count(*) FROM filevisible WHERE userID='".$_SESSION['userid']."' AND fileID='".$this->fileID."'");                                                                                                                                                         
     240               0 :                 if ($visible < 1) continue;                                                                                                                                                                                                                                                                
     241               0 :             }                                                                                                                                                                                                                                                                                              
     242               0 :         }                                                                                                                                                                                                                                                                                                  
     243               0 :         $CELL = $cssClass;                                                                                                                                                                                                                                                                                 
     244                 :         // Symbole                                                                                                                                                                                                                                                                                         
     245                 :                                                                                                                                                                                                                                                                                                            
     246               0 :         global $db;                                                                                                                                                                                                                                                                                        
     247               0 :         $user = $db->get_row("SELECT Vorname, Nachname, gender FROM user WHERE ID='".$this->userID."'");                                                                                                                                                                                                   
     248                 :                                                                                                                                                                                                                                                                                                            
     249                 :         // Username inkl Gruppennamen anzeigen                                                                                                                                                                                                                                                             
     250               0 :         $courseID = $_SESSION["course"];                                                                                                                                                                                                                                                                   
     251               0 :         $groupName = UserTools::getUserGroupName($this->userID, $courseID);                                                                                                                                                                                                                                
     252               0 :         $userName = $user->Vorname . " " . $user->Nachname . " ($groupName)";                                                                                                                                                                                                                              
     253                 :                                                                                                                                                                                                                                                                                                            
     254                 :         // Zeigt wenn vorhanden ein Extension basierendes Icon an (extension.gif/png (einzige mit Transparenz)) im Ordner ressourcen/icons/filetypes                                                                                                                                                       
     255                 :         // BZW Standardfiles fuer Link und Dateien                                                                                                                                                                                                                                                         
     256               0 :         $fileTypeImage = $imgFolder."filetypes/";                                                                                                                                                                                                                                                          
     257               0 :         if ($this->type == "link") {                                                                                                                                                                                                                                                                       
     258               0 :             $fileTypeImage.= "link.gif";                                                                                                                                                                                                                                                                   
     259                 :             // Prueft ob ein favicon vorhanden ist, und zeigt dann dieses als Symbol an.                                                                                                                                                                                                                   
     260               0 :             $url = @parse_url($this->link);                                                                                                                                                                                                                                                                
     261               0 :             if ($url['scheme'] == '') $url['scheme'] = "http";                                                                                                                                                                                                                                             
     262               0 :             if ($url['host'] != '') {                                                                                                                                                                                                                                                                      
     263               0 :                 if ($this->remoteFileExists($url['scheme']."://".$url['host']."/favicon.ico")) {                                                                                                                                                                                                           
     264               0 :                     $fileTypeImage = $url['scheme']."://".$url['host']."/favicon.ico";                                                                                                                                                                                                                     
     265               0 :                 } elseif ($favicon = $this->getFaviconUrl($url['scheme']."://".$url['host'])) {                                                                                                                                                                                                            
     266               0 :                     $urlTest = @parse_url($favicon);                                                                                                                                                                                                                                                       
     267               0 :                     if (isset($urlTest['scheme']) && $urlTest['scheme'] == '') $favicon = $url['scheme']."://".$url['host'].'/'.$favicon;                                                                                                                                                                  
     268               0 :                     if ($this->remoteFileExists($favicon)) $fileTypeImage = $favicon;                                                                                                                                                                                                                      
     269               0 :                 }                                                                                                                                                                                                                                                                                          
     270               0 :             }                                                                                                                                                                                                                                                                                              
     271               0 :         } elseif ($this->type == "file") {                                                                                                                                                                                                                                                                 
     272               0 :             if (file_exists($imgFolder."filetypes/".$this->extension.".gif")) $fileTypeImage.= $this->extension.".gif";                                                                                                                                                                                    
     273               0 :             elseif (file_exists($imgFolder."filetypes/".$this->extension.".png")) $fileTypeImage.= $this->extension.".png";                                                                                                                                                                                
     274               0 :             else  {$fileTypeImage.= "file.gif";                                                                                                                                                                                                                                                            
     275               0 :             $this->extension = "file";}                                                                                                                                                                                                                                                                    
     276               0 :         }                                                                                                                                                                                                                                                                                                  
     277               0 :         $IMG = "<img width='18' height='16' src='".$fileTypeImage."' alt='Dateisymbol' />";                                                                                                                                                                                                                
     278                 : //Performance-Tuning: Image wird als CSS-Sprite geladen (deaktiviert, weil nicht alle Icons im CSS-Sprite enthalten)                                                                                                                                                                                       
     279                 : //        if($_SESSION["UserStyle"] != "fh_yaml")                                                                                                                                                                                                                                                          
     280                 : //            $IMG = "<img width='18' height='16' src='".$fileTypeImage."' alt='Dateisymbol' />";                                                                                                                                                                                                          
     281                 : //        else {                                                                                                                                                                                                                                                                                           
     282                 : //            if ($this->type == "link") {                                                                                                                                                                                                                                                                 
     283                 : //                $IMG = "<img width='18' height='16' src='".$fileTypeImage."' alt='Dateisymbol' />";                                                                                                                                                                                                      
     284                 : //            } else {                                                                                                                                                                                                                                                                                     
     285                 : //                $IMG = "<img src='".PATH_TO_ROOT."images/transparent.gif' class='icon_extension_".$this->extension."' alt='Dateisymbol' />";                                                                                                                                                             
     286                 : //            }                                                                                                                                                                                                                                                                                            
     287                 : //        }                                                                                                                                                                                                                                                                                                
     288                 :         // Fuer TOP20 wird angezeigt ob Kurs oder Foyer Datei.                                                                                                                                                                                                                                             
     289               0 :         if ($activeFolder < 0 && $this->courseID == 0 && $_SESSION['course'] != 0) $this->name = "".$this->name."<span class='text10'><strong>&nbsp;&nbsp;(Foyer)</strong></span>";                                                                                                                        
     290                 :                                                                                                                                                                                                                                                                                                            
     291                 :         //########### Ist Zeile ausgewählt, dann markieren und Hover Effekt unterbinden                                                                                                                                                                                                                   
     292               0 :         if (isset($_GET['actionID']) && $_GET['actionID'] == $this->fileID) {                                                                                                                                                                                                                              
     293               0 :             $FILESELECT = 'res_fileselect';                                                                                                                                                                                                                                                                
     294               0 :             $FILE_CLASS = '';                                                                                                                                                                                                                                                                              
     295               0 :         } else {                                                                                                                                                                                                                                                                                           
     296               0 :             $FILESELECT = '';                                                                                                                                                                                                                                                                              
     297               0 :             $FILE_CLASS = 'res_file';                                                                                                                                                                                                                                                                      
     298                 :         }                                                                                                                                                                                                                                                                                                  
     299               0 :         $FILE_NAME = Data::toHTML($this->name, false);                                                                                                                                                                                                                                                     
     300                 :                                                                                                                                                                                                                                                                                                            
     301               0 :         if ($this->type == 'link') {                                                                                                                                                                                                                                                                       
     302               0 :             $this->size = "Link";                                                                                                                                                                                                                                                                          
     303               0 :         } else {                                                                                                                                                                                                                                                                                           
     304               0 :             $this->size = Format::FilesizeStr($this->size);                                                                                                                                                                                                                                                
     305                 :         }                                                                                                                                                                                                                                                                                                  
     306                 :                                                                                                                                                                                                                                                                                                            
     307               0 :         $downloadStats = ( $statisticView ) ? $this->getDownloadStatisticHTML() : "";                                                                                                                                                                                                                      
     308               0 :         $LINK = ( $statisticView ) ? $this->getStatisticLink() : $this->getFileLink();                                                                                                                                                                                                                     
     309                 :                                                                                                                                                                                                                                                                                                            
     310                 :         // Link auf BenutzerProfil                                                                                                                                                                                                                                                                         
     311               0 :         $userLink = "<a href='".PATH_TO_ROOT."user/homepage.php?user=$this->userID'>".Data::toHTML("$userName", false) ."</a>";                                                                                                                                                                            
     312               0 :         if ($role = RoleArtefacts::getRoleForItem(RESSOURCE, (int)$this->fileID)) {                                                                                                                                                                                                                        
     313               0 :             $userLink.= " (".$role->getPropertiesLink($role->getName($user->gender)) .")";                                                                                                                                                                                                                 
     314               0 :         }                                                                                                                                                                                                                                                                                                  
     315               0 :         if ($team = TeamArtefacts::getTeamForItem(RESSOURCE, (int)$this->fileID)) {                                                                                                                                                                                                                        
     316               0 :             $userLink.= " (".Data::toHTML($team->getName(), false) .")";                                                                                                                                                                                                                                   
     317               0 :         }                                                                                                                                                                                                                                                                                                  
     318               0 :         $tableData = array();                                                                                                                                                                                                                                                                              
     319               0 :         $tableData["resource"] = $LINK.$IMG. $FILE_NAME . $downloadStats . "</a>";                                                                                                                                                                                                                         
     320               0 :         if ( !$statisticView )$tableData["action"] = $this->getUserIcons();                                                                                                                                                                                                                                
     321               0 :         $tableData["size"] = $this->size;                                                                                                                                                                                                                                                                  
     322               0 :         $tableData["created"] = Output::echoDate("d.m.Y H:i", (int)$this->createTime);                                                                                                                                                                                                                     
     323               0 :         $tableData["owner"] = $userLink;                                                                                                                                                                                                                                                                   
     324               0 :         $tableData["clicks"] = $this->counter;                                                                                                                                                                                                                                                             
     325               0 :         if ( $statisticView ) {                                                                                                                                                                                                                                                                            
     326               0 :             $courseCount = $db->get_var("SELECT count(*) FROM user_course ".($this->courseID == 0 ? "" : " WHERE courseID='".$this->courseID."' AND userID!=1"));                                                                                                                                          
     327               0 :             $klicks = $db->get_var("SELECT DISTINCT count(userID) FROM filelog WHERE fileID='".$this->fileID."' AND userID!=1 GROUP BY fileID");                                                                                                                                                           
     328               0 :             $prozent = sprintf("%3.2f%%", ($klicks*100) /$courseCount);                                                                                                                                                                                                                                    
     329               0 :             $tableData["clicks"] .= "/" . $prozent;                                                                                                                                                                                                                                                        
     330               0 :         }                                                                                                                                                                                                                                                                                                  
     331                 :                                                                                                                                                                                                                                                                                                            
     332               0 :         $htmlString = "";                                                                                                                                                                                                                                                                                  
     333               0 :         eval( $templateTableRow->getTemplate("htmlString") );                                                                                                                                                                                                                                              
     334               0 :         if ( $actionID == $this->fileID ) {                                                                                                                                                                                                                                                                
     335               0 :             if ( $statisticView ) {                                                                                                                                                                                                                                                                        
     336               0 :                 if ( $action == "showInfo" ) $htmlString .= $this->getStatisticHTML();                                                                                                                                                                                                                     
     337               0 :             } else {                                                                                                                                                                                                                                                                                       
     338               0 :                 $htmlString .= $this->getFileOptionHTML( $action );                                                                                                                                                                                                                                        
     339                 :             }                                                                                                                                                                                                                                                                                              
     340               0 :         }                                                                                                                                                                                                                                                                                                  
     341                 :                                                                                                                                                                                                                                                                                                            
     342               0 :         return $htmlString;                                                                                                                                                                                                                                                                                
     343                 :     }                                                                                                                                                                                                                                                                                                      
     344                 :                                                                                                                                                                                                                                                                                                            
     345                 :     public function getFileOptionHTML( $option ) {                                                                                                                                                                                                                                                         
     346                 :         switch ( $option ) {                                                                                                                                                                                                                                                                               
     347               0 :             case "deleteFile":                                                                                                                                                                                                                                                                             
     348               0 :                 return $this->getDeleteFileHTML();                                                                                                                                                                                                                                                         
     349               0 :             case "copyFile":                                                                                                                                                                                                                                                                               
     350               0 :                 return $this->getCopyFileHTML();                                                                                                                                                                                                                                                           
     351               0 :             case "infoFile":                                                                                                                                                                                                                                                                               
     352               0 :                 return $this->getDescriptionHTML();                                                                                                                                                                                                                                                        
     353               0 :             case "setRessourceVisibility":                                                                                                                                                                                                                                                                 
     354                 :                 return  "<tr><td colspan='5'>"                                                                                                                                                                                                                                                             
     355               0 :                         .$this->getRessourceVisibilityHTML()                                                                                                                                                                                                                                               
     356               0 :                         ."</td></tr>";                                                                                                                                                                                                                                                                     
     357                 :         }                                                                                                                                                                                                                                                                                                  
     358               0 :         return "";                                                                                                                                                                                                                                                                                         
     359                 :     }                                                                                                                                                                                                                                                                                                      
     360                 :                                                                                                                                                                                                                                                                                                            
     361                 :     private function getCopyFileHTML() {                                                                                                                                                                                                                                                                   
     362               0 :             $template = new Template(PATH_TO_ROOT . "/ressourcen/templates/copyfile.html");                                                                                                                                                                                                                
     363               0 :             $courses = RessourcenDB::getUserCourses( $_SESSION['userid'] );                                                                                                                                                                                                                                
     364               0 :             $currentCourse = 0;                                                                                                                                                                                                                                                                            
     365               0 :             $courseOptions = "";                                                                                                                                                                                                                                                                           
     366               0 :             if ( $_SESSION['course'] != 0 ) {                                                                                                                                                                                                                                                              
     367               0 :                 $courseOptions .= "<option value='0'>Foyer</option>\n";                                                                                                                                                                                                                                    
     368               0 :             }                                                                                                                                                                                                                                                                                              
     369               0 :             foreach($courses as $course) {                                                                                                                                                                                                                                                                 
     370               0 :                 if ($currentCourse == $course->ID) {                                                                                                                                                                                                                                                       
     371               0 :                      $courseOptions .= ", ".Data::toHTML($course->ShortName, false);                                                                                                                                                                                                                       
     372               0 :                 } else {                                                                                                                                                                                                                                                                                   
     373               0 :                     if ($currentCourse != 0)  $courseOptions .= ")</option>\n";                                                                                                                                                                                                                            
     374               0 :                     $courseOptions .= "<option value='".$course->ID."'";                                                                                                                                                                                                                                   
     375               0 :                     $courseOptions .= ">".Data::toHTML($course->SN." (".$course->ShortName, false);                                                                                                                                                                                                        
     376               0 :                     $currentCourse = $course->ID;                                                                                                                                                                                                                                                          
     377                 :                 }                                                                                                                                                                                                                                                                                          
     378               0 :             }                                                                                                                                                                                                                                                                                              
     379               0 :             $courseOptions .= ")</option>\n";                                                                                                                                                                                                                                                              
     380               0 :             $folderID = $this->fileManager->getActiveFolder();                                                                                                                                                                                                                                             
     381               0 :             $fileID = $this->fileID;                                                                                                                                                                                                                                                                       
     382               0 :             $html = "";                                                                                                                                                                                                                                                                                    
     383               0 :             eval ( $template->getTemplate( "html" ) );                                                                                                                                                                                                                                                     
     384               0 :             return $html;                                                                                                                                                                                                                                                                                  
     385                 :     }                                                                                                                                                                                                                                                                                                      
     386                 :                                                                                                                                                                                                                                                                                                            
     387                 :     private function getFileLink() {                                                                                                                                                                                                                                                                       
     388               0 :         if ($this->type == 'file') {                                                                                                                                                                                                                                                                       
     389               0 :             $LINK = "<a class='file' href='".$this->createLink(0, array("activeFolder" => $this->fileManager->getActiveFolder(), "action" => 'get'.$this->type, 'actionID' => $this->fileID)) ."' title='Dateiname: ".Data::toHTML($this->origFileName, false) ."'>";                                      
     390               0 :         } elseif ($this->type == 'link') {                                                                                                                                                                                                                                                                 
     391               0 :             $LINK = "<a class='file' href='".$this->createLink(0, array("activeFolder" => $this->fileManager->getActiveFolder(), "action" => 'get'.$this->type, 'actionID' => $this->fileID)) ."' title='URL: ".Data::toHTML($this->link, false) ."'>";                                                    
     392               0 :         }                                                                                                                                                                                                                                                                                                  
     393               0 :         return $LINK;                                                                                                                                                                                                                                                                                      
     394                 :     }                                                                                                                                                                                                                                                                                                      
     395                 :                                                                                                                                                                                                                                                                                                            
     396                 :     private function getStatisticLink() {                                                                                                                                                                                                                                                                  
     397               0 :         if ($this->type == 'file') {                                                                                                                                                                                                                                                                       
     398               0 :             $LINK = "<a class='file' href='".Filemanager::createLink(0, array("activeFolder" => $this->fileManager->getActiveFolder(), "action" => 'showInfo', 'actionID' => $this->fileID, 'show' => 'down')) ."' title='Dateiname (Studenten heruntergeladen/Gesamt Studenten im Kurs)'>";               
     399               0 :         } elseif ($this->type == 'link') {                                                                                                                                                                                                                                                                 
     400               0 :             $LINK = "<a class='file' href='".Filemanager::createLink(0, array("activeFolder" => $this->fileManager->getActiveFolder(), "action" => 'showInfo', 'actionID' => $this->fileID, 'show' => 'down')) ."' title='URL: ".Data::toHTML($this->link, false) ."'>";                                   
     401               0 :         }                                                                                                                                                                                                                                                                                                  
     402               0 :         return $LINK;                                                                                                                                                                                                                                                                                      
     403                 :     }                                                                                                                                                                                                                                                                                                      
     404                 :                                                                                                                                                                                                                                                                                                            
     405                 :     private function getDownloadCount() {                                                                                                                                                                                                                                                                  
     406               0 :         global $db;                                                                                                                                                                                                                                                                                        
     407               0 :         if ($this->courseID == 0) {                                                                                                                                                                                                                                                                        
     408               0 :             $count = (int) $db->get_var("SELECT DISTINCT count(filelog.userID) FROM filelog LEFT JOIN user ON (filelog.userID=user.ID) WHERE fileID='".$this->fileID."' AND filelog.userID!=1 group BY fileID");                                                                                           
     409               0 :         } else {                                                                                                                                                                                                                                                                                           
     410               0 :             $count = (int) $db->get_var("SELECT DISTINCT count(filelog.userID) FROM filelog LEFT JOIN user_course ON (filelog.userID=user_course.userID) WHERE fileID='".$this->fileID."' AND filelog.userID!=1 AND user_course.courseID='".$this->courseID."' group BY fileID");                          
     411                 :         }                                                                                                                                                                                                                                                                                                  
     412               0 :         return $count;                                                                                                                                                                                                                                                                                     
     413                 :     }                                                                                                                                                                                                                                                                                                      
     414                 :                                                                                                                                                                                                                                                                                                            
     415                 :     private function getDownloadStatisticHTML() {                                                                                                                                                                                                                                                          
     416               0 :         global $db;                                                                                                                                                                                                                                                                                        
     417               0 :         $downloadCount = $this->getDownloadCount();                                                                                                                                                                                                                                                        
     418               0 :         if ($this->courseID == 0) {                                                                                                                                                                                                                                                                        
     419               0 :             $allCount = $db->get_var("SELECT COUNT(*) FROM user WHERE ID!=1");                                                                                                                                                                                                                             
     420               0 :          } else {                                                                                                                                                                                                                                                                                          
     421               0 :             $allCount = $db->get_var("SELECT COUNT(*) FROM user_course WHERE courseID='".$file->courseID."' AND userID!=1");                                                                                                                                                                               
     422                 :          }                                                                                                                                                                                                                                                                                                 
     423               0 :          return " (".$downloadCount."/".$allCount.")";                                                                                                                                                                                                                                                     
     424                 :     }                                                                                                                                                                                                                                                                                                      
     425                 :                                                                                                                                                                                                                                                                                                            
     426                 :                                                                                                                                                                                                                                                                                                            
     427                 :     private function getDeleteFileHTML() {                                                                                                                                                                                                                                                                 
     428               0 :             $template = new Template(PATH_TO_ROOT . "/ressourcen/templates/deletefile.html");                                                                                                                                                                                                              
     429               0 :             $folderID = $this->fileManager->getActiveFolder();                                                                                                                                                                                                                                             
     430               0 :             $fileID = $this->fileID;                                                                                                                                                                                                                                                                       
     431               0 :             $html = "";                                                                                                                                                                                                                                                                                    
     432               0 :             eval ( $template->getTemplate( "html" ) );                                                                                                                                                                                                                                                     
     433               0 :             return $html;                                                                                                                                                                                                                                                                                  
     434                 :     }                                                                                                                                                                                                                                                                                                      
     435                 :                                                                                                                                                                                                                                                                                                            
     436                 :     private function getDescriptionHTML() {                                                                                                                                                                                                                                                                
     437               0 :         $bbcode = new BBCode();                                                                                                                                                                                                                                                                            
     438               0 :         if (!$this->description) $this->description = "Keine Beschreibung vorhanden";                                                                                                                                                                                                                      
     439               0 :         return "<tr><td class='res_file-extra' colspan='6'>".$bbcode->parse($this->description) ."</td></tr>";                                                                                                                                                                                             
     440                 :     }                                                                                                                                                                                                                                                                                                      
     441                 :                                                                                                                                                                                                                                                                                                            
     442                 :     private function getStatisticHTML() {                                                                                                                                                                                                                                                                  
     443               0 :                 global $db;                                                                                                                                                                                                                                                                                
     444               0 :                 $CELL1 = $CELL = 'tableCellDark'; // AnfangsKlasse fuer Tabellenzeile, wechselt                                                                                                                                                                                                            
     445               0 :                    $CELL2 = 'tableCell';                                                                                                                                                                                                                                                                   
     446               0 :                    $html = "";                                                                                                                                                                                                                                                                             
     447                 :                                                                                                                                                                                                                                                                                                            
     448               0 :                 if ($this->courseID == 0) {                                                                                                                                                                                                                                                                
     449               0 :                     $allCount = $db->get_var("SELECT COUNT(*) FROM user WHERE ID!=1");                                                                                                                                                                                                                     
     450               0 :                     $downCount = $db->get_var("SELECT DISTINCT count(userID) FROM filelog WHERE fileID='".$this->fileID."' AND userID!=1 GROUP BY fileID");                                                                                                                                                
     451               0 :                 } else {                                                                                                                                                                                                                                                                                   
     452               0 :                     $allCount = $db->get_var("SELECT COUNT(*) FROM user_course WHERE courseID='".$this->courseID."' AND userID!=1");                                                                                                                                                                       
     453               0 :                     $downCount = $db->get_var("SELECT DISTINCT count(filelog.userID) FROM filelog LEFT JOIN user_course ON (filelog.userID=user_course.userID) WHERE fileID='".$this->fileID."' AND filelog.userID!=1 AND user_course.courseID='".$this->courseID."' group BY fileID");                    
     454                 :                 }                                                                                                                                                                                                                                                                                          
     455               0 :                 if ($downCount == "") $downCount = 0;                                                                                                                                                                                                                                                      
     456               0 :                 $notDownCount = $allCount-$downCount;                                                                                                                                                                                                                                                      
     457               0 :                 $html .= "<tr><td class='res_file-extra' colspan='5'>";                                                                                                                                                                                                                                    
     458               0 :                 $html .= "Anzeigen: &nbsp;&nbsp;";                                                                                                                                                                                                                                                         
     459                 :                 // Listet alle Kursteilnehmer aus.. Nach bitte von KQC entfernt                                                                                                                                                                                                                            
     460                 :                 //$html .= "<a href='".Filemanager::createLink(1,array('show'=>'all'))."'>".($_GET['show']=='all'?"<b><span class="underline">Alle</span></b>":"Alle")." (".$allCount.")</a> | ";                                                                                                          
     461               0 :                 $html .= "[ <a href='".Filemanager::createLink(1, array('show' => 'down')) ."'>".($_GET['show'] == 'down' ? "Downloader" : "Downloader") ." (".$downCount.")</a> | ";                                                                                                                      
     462               0 :                 $html .= "<a href='".Filemanager::createLink(1, array('show' => 'notDown')) ."'>".($_GET['show'] == 'notDown' ? "Nicht-Downloader" : "Nicht-Downloader") ." (".$notDownCount.")</a> ]";                                                                                                    
     463               0 :                 $html .= "&nbsp;&nbsp;&nbsp;=> Gesamt: ".$allCount;                                                                                                                                                                                                                                        
     464               0 :                 $html .= "<table class='res_statuserlist'><tr><td class='tableCellHead'>Nr.</td><td class='tableCellHead' style='text-align: left;'>Person</td><td class='tableCellHead'>Anzahl</td><td class='tableCellHead' style='text-align: right;'>Letzter Zugriff</td></tr>";                       
     465               0 :                 $count = 0;                                                                                                                                                                                                                                                                                
     466               0 :                 switch ($_GET['show']) { // Was wird angezeigt, down oder not_down                                                                                                                                                                                                                         
     467                 :                                                                                                                                                                                                                                                                                                            
     468               0 :                     case 'down': // Zeigt alle User die dieses File Downgeloadet haben                                                                                                                                                                                                                     
     469               0 :                         $logs = $db->get_results("SELECT DISTINCT userID, date, count(userID) AS klicks FROM filelog WHERE fileID='".$this->fileID."' AND userID!=1 GROUP BY userID ORDER BY userID, date");                                                                                               
     470               0 :                         if ($logs) foreach($logs as $log) {                                                                                                                                                                                                                                                
     471               0 :                             $user = $db->get_var("SELECT concat(Nachname,', ',Vorname) AS name FROM user WHERE ID='".$log->userID."'");                                                                                                                                                                    
     472               0 :                             if (!isset($user)) continue;                                                                                                                                                                                                                                                   
     473               0 :                             $data[$user][0] = $log->userID;                                                                                                                                                                                                                                                
     474               0 :                             $data[$user][1] = Data::toHTML($user, false);                                                                                                                                                                                                                                  
     475               0 :                             $data[$user][2] = $log->date;                                                                                                                                                                                                                                                  
     476               0 :                             $data[$user][3] = $log->klicks;                                                                                                                                                                                                                                                
     477               0 :                         }                                                                                                                                                                                                                                                                                  
     478               0 :                         if (!empty($data)) {                                                                                                                                                                                                                                                               
     479               0 :                             ksort($data); // Array wird nach UserName sortiert                                                                                                                                                                                                                             
     480               0 :                             foreach($data as $value) { //Gibt Namensliste aus                                                                                                                                                                                                                              
     481               0 :                                 $CELL = ($CELL == $CELL1 ? $CELL2 : $CELL1);                                                                                                                                                                                                                               
     482               0 :                                 $userLink = PATH_TO_ROOT."user/homepage.php?user=".$value[0];                                                                                                                                                                                                              
     483               0 :                                 $html .= "<tr><td class='$CELL'>".++$count."</td><td class='$CELL' style='text-align: left;'><a href='$userLink'>".$value[1]."</a></td><td class='$CELL' >".$value[3]."</td><td class='$CELL' style='text-align: right;'>".Date("d.m.Y H:i", (int)$value[2]) ."</td></tr>";
     484               0 :                             }                                                                                                                                                                                                                                                                              
     485               0 :                         }                                                                                                                                                                                                                                                                                  
     486               0 :                         break;                                                                                                                                                                                                                                                                             
     487                 :                                                                                                                                                                                                                                                                                                            
     488               0 :                     case 'notDown': // Alle user die es nicht downgeloadet haben                                                                                                                                                                                                                           
     489               0 :                         if ($this->courseID == 0) {                                                                                                                                                                                                                                                        
     490               0 :                             $users = $db->get_results("SELECT ID, concat(Nachname,', ',Vorname) AS name FROM user WHERE ID!=1 ORDER BY name");                                                                                                                                                             
     491               0 :                         } else {                                                                                                                                                                                                                                                                           
     492               0 :                             $users = $db->get_results("SELECT ID, concat(Nachname,', ',Vorname) AS name FROM user_course LEFT OUTER JOIN user ON (user_course.userID=user.ID) WHERE ID!=1 AND user_course.courseID='".$this->courseID."' ORDER BY name");                                                  
     493                 :                         }                                                                                                                                                                                                                                                                                  
     494               0 :                         if ($users) foreach($users as $user) {                                                                                                                                                                                                                                             
     495               0 :                             $userLink = PATH_TO_ROOT."user/homepage.php?user=".$user->ID;                                                                                                                                                                                                                  
     496               0 :                             $log = $db->get_var("SELECT DISTINCT count(filelog.userID) AS klicks FROM filelog LEFT JOIN user_course ON (filelog.userID=user_course.userID)  WHERE filelog.userID='".$user->ID."' AND fileID='".$this->fileID."' GROUP BY filelog.userID");                                 
     497               0 :                             if ($log != 0) continue;                                                                                                                                                                                                                                                       
     498               0 :                             $CELL = ($CELL == $CELL1 ? $CELL2 : $CELL1);                                                                                                                                                                                                                                   
     499               0 :                             $html .= "<tr><td class='$CELL'>".++$count."</td><td class='$CELL' style='text-align: left;'><a href='$userLink'>".Data::toHTML($user->name, false) ."</a></td><td class='$CELL' >0</td><td class='$CELL' style='text-align: right;'>Nie</td></tr>";                           
     500               0 :                         }                                                                                                                                                                                                                                                                                  
     501                 :                         //$logs = $db->get_results("SELECT concat(Nachname,', ',Vorname) AS name FROM user, user_course WHERE user_course.userID=user.ID AND ID!='".$log->userID."'");                                                                                                                     
     502               0 :                         break;                                                                                                                                                                                                                                                                             
     503                 :                                                                                                                                                                                                                                                                                                            
     504               0 :                     case 'all': // Zeige ALLE User des Kurses an... ZZT DEAKTIVIERT                                                                                                                                                                                                                        
     505               0 :                         if ($this->courseID == 0) {                                                                                                                                                                                                                                                        
     506               0 :                             $users = $db->get_results("SELECT ID, concat(Vorname,' ',Nachname) AS name FROM user ORDER BY name");                                                                                                                                                                          
     507               0 :                         } else {                                                                                                                                                                                                                                                                           
     508               0 :                             $users = $db->get_results("SELECT ID, concat(Vorname,' ',Nachname) AS name FROM user_course LEFT OUTER JOIN user ON (user_course.userID=user.ID) WHERE user_course.courseID='".$this->courseID."' ORDER BY name");                                                             
     509                 :                         }                                                                                                                                                                                                                                                                                  
     510               0 :                         if ($users) foreach($users as $user) {                                                                                                                                                                                                                                             
     511               0 :                             $CELL = ($CELL == $CELL1 ? $CELL2 : $CELL1);                                                                                                                                                                                                                                   
     512               0 :                             $userLink = PATH_TO_ROOT."user/homepage.php?user=".$user->ID;                                                                                                                                                                                                                  
     513               0 :                             $log = $db->get_row("SELECT DISTINCT count(userID) AS klicks, date FROM filelog WHERE userID='".$user->ID."' AND fileID='".$this->fileID."' GROUP BY userID");                                                                                                                 
     514               0 :                             $date = Output::$html .=Date("d.m.Y H:i", (int)$log->date);                                                                                                                                                                                                                    
     515               0 :                             if ($log->date == 0) $date = "Nie";                                                                                                                                                                                                                                            
     516               0 :                             if ($log->klicks == 0) $log->klicks = "0";                                                                                                                                                                                                                                     
     517               0 :                             $html .= "<tr><td class='$CELL' >".++$count."</td><td class='$CELL' ><a href='$userLink'>".Data::toHTML($user->name, false) ."</a></td><td class='$CELL' >".$log->klicks."</td><td class='$CELL'  style='font-size:10px;text-align:right;' >".$date."</td></tr>";              
     518               0 :                         }                                                                                                                                                                                                                                                                                  
     519               0 :                         break;                                                                                                                                                                                                                                                                             
     520               0 :                     }                                                                                                                                                                                                                                                                                      
     521               0 :                     $html .= "</table></td></tr>";                                                                                                                                                                                                                                                         
     522               0 :                     return $html;                                                                                                                                                                                                                                                                          
     523                 :                                                                                                                                                                                                                                                                                                            
     524                 :     }                                                                                                                                                                                                                                                                                                      
     525                 :                                                                                                                                                                                                                                                                                                            
     526                 :     /**                                                                                                                                                                                                                                                                                                    
     527                 :      * Archiver accept method for ArchiveVisitor                                                                                                                                                                                                                                                           
     528                 :      *                                                                                                                                                                                                                                                                                                     
     529                 :      * @param ArchiveVisitor $visitor                                                                                                                                                                                                                                                                      
     530                 :      * @param String $parentPath Parent path                                                                                                                                                                                                                                                               
     531                 :      * @return Sting Parent path                                                                                                                                                                                                                                                                           
     532                 :      */                                                                                                                                                                                                                                                                                                    
     533                 :     public function archiverAccept(ResourceVisitor $visitor, $parentPath = "/") {                                                                                                                                                                                                                          
     534               0 :         assert($visitor instanceof ResourceVisitor);                                                                                                                                                                                                                                                       
     535                 :                                                                                                                                                                                                                                                                                                            
     536               0 :         return $visitor->visit($this, $parentPath);                                                                                                                                                                                                                                                        
     537                 :     }                                                                                                                                                                                                                                                                                                      
     538                 : }                                                                                                                                                                                                                                                                                                          

Generated by PHPUnit 3.2.21 and Xdebug 2.0.4 at Sat Nov 7 22:04:08 CET 2009.